package com.peter.roomdemo;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.example.inventory.data.Item;
import com.example.inventory.data.ItemDao;
import com.example.inventory.data.ItemRoomDatabase;
import com.peter.roomdemo.data.MyAppDatabase;
import com.peter.roomdemo.data.User;
import com.peter.roomdemo.data.UserManager;

import java.util.List;

public class MainActivity extends AppCompatActivity {
    private final static String TAG = MainActivity.class.getSimpleName();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button bt = findViewById(R.id.bt);

        bt.setOnClickListener(view -> {
            Log.e(TAG, "onCreate: ", null);
            User user = new User();
            // primary key
            user.userId = 2;
            user.userName = "peter";
            user.userAge = 22;

            UserManager.addUser(MainActivity.this, user);

            List<User> l = UserManager.getUsers(MainActivity.this);

            l.forEach(System.out::println);

        });

    }
}